{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    ">原文地址 [www.cnblogs.com](https://www.cnblogs.com/huangenai/p/10012672.html)\n",
    "\n",
    "### 拉取镜像\n",
    "\n",
    "```sh\n",
    "docker pull registry\n",
    "```\n",
    "\n",
    "### 运行 registry\n",
    "\n",
    "```sh\n",
    "run -d -p 5000:5000 -v /Users/huangenai/docker/registry:/var/lib/registry registry\n",
    "```\n",
    "\n",
    "\\-d 后台运行   -p 指定端口  -v 把 registry 的镜像路径 / var/lib/registry 映射到本机的 Users/huangenai/docker/registry\n",
    "\n",
    "```sh\n",
    "//查看运行容器\n",
    "docker ps\n",
    "```\n",
    "\n",
    "![](https://img2018.cnblogs.com/blog/833855/201811/833855-20181124134416147-529234705.png)\n",
    "\n",
    "### 进入容器 \n",
    "\n",
    "```sh\n",
    "//进入容器  22da3fb569ea是容器id 在上一步骤中获得 \n",
    "sudo docker attach 22da3fb569ea\n",
    "```\n",
    "\n",
    "本地仓库非安全配置 user\\<username>.docker/daemon.json\n",
    "\n",
    "\n",
    "```sh\n",
    "cat .docker/daemon.json \n",
    "{\n",
    "  \"insecure-registries\" : [\n",
    "    \"127.0.0.1:5000\"\n",
    "  ],\n",
    "  \"debug\" : true,\n",
    "  \"experimental\" : true,\n",
    "  \"registry-mirrors\" : [\n",
    "    \"https://8q2dp9p9.mirror.aliyuncs.com\"\n",
    "  ]\n",
    "}\n",
    "```\n",
    "\n",
    "![](https://img2018.cnblogs.com/blog/833855/201811/833855-20181124135107129-1188301137.png)\n",
    "\n",
    "查看仓库中的镜像\n",
    "\n",
    "```\n",
    "curl -XGET http://127.0.0.1:5000/v2/\\_catalog\n",
    "```\n",
    "\n",
    "p.p1 {margin: 0; font: 11px Menlo; color: rgba(0, 0, 0, 1) } span.s1 { font-variant-ligatures: no-common-ligatures }\n",
    "\n",
    "```\n",
    "git clone https://git.oschina.net/kbsonlong/Breezes.git\n",
    "```\n",
    "\n",
    "找到里面的 Dockerfile 文件，修改如下\n",
    "\n",
    "```sh\n",
    "FROM centos\n",
    "\n",
    "MAINTAINER Mr.tao <staugur@saintic.com>\n",
    "\n",
    "ADD src /Breezes\n",
    "\n",
    "ADD misc/supervisord.conf /etc/supervisord.conf\n",
    "\n",
    "ADD requirements.txt /tmp\n",
    "\n",
    "WORKDIR /Breezes\n",
    "\n",
    "RUN yum -y update \n",
    "RUN yum -y install wget gcc python-devel \n",
    "RUN wget https://bootstrap.pypa.io/get-pip.py \n",
    "RUN python get-pip.py \n",
    "RUN pip install --timeout 30 --index https://pypi.douban.com/simple/ -r /tmp/requirements.txt\n",
    "\n",
    "EXPOSE 10210\n",
    "\n",
    "ENTRYPOINT \\[\"supervisord\"\\]\n",
    "\n",
    "```\n",
    "\n",
    "```sh\n",
    "//构建镜像\n",
    "docker build -t breezes .\n",
    "\n",
    "//运行镜像\n",
    "docker run -d -p 10210:10210 --restart=always -h breezes \\\\\n",
    "--name breezes breezes\n",
    "\n",
    "//保存镜像到私有仓库\n",
    "docker tag breezes 127.0.0.1:5000/breezes\n",
    "docker push 127.0.0.1:5000/breezes\n",
    "\n",
    "```\n",
    "\n",
    "打开  http://0.0.0.0:10210/ui/\n",
    "\n",
    "效果\n",
    "\n",
    "![](https://img2018.cnblogs.com/blog/833855/201811/833855-20181124164908858-1630843017.png)\n",
    "\n",
    "上面这个例子已经包含了如何创建一个镜像以及将它存入私有仓库了，这里就不再重复了。\n",
    "\n",
    "参考：\n",
    "\n",
    "- http://blog.51cto.com/13673090/2092462\n",
    "\n",
    "- https://gitee.com/kbsonlong/Breezes\n",
    "\n",
    "此随笔乃本人学习工作记录，如有疑问欢迎在下面评论，转载请标明出处。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
